package operation.impl;

import book.Book;
import book.BookList;
import operation.IOperation;

public class AddOperation implements IOperation {
    public void work(BookList bookList){
        System.out.println("您现在进行的是书籍的添加操作");
        System.out.println("请输入书籍名称->");
        String booksName = scanner.next();
        if(bookList.isContains(booksName)){
            System.err.println("书架上已经存在该书，无需再次添加~");
            return;
        }else {
            System.out.println("请输入书籍作者->");
            String author = scanner.next();
            System.out.println("请输入书籍的价格->");
            double prise = scanner.nextDouble();
            System.out.println("请输入书籍的类别->");
            String type = scanner.next();
            Book book = new Book(booksName,author,prise,type);
            bookList.addBook(book);
            System.out.println("书籍添加成功！");
        }
    }
}
